/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sineandcosine;
import java.io.*;
import java.math.*;
/**
 *
 * @author hhl
 */
public class SineAndCosine {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        double angle=0.0;
        String s="";
        int mode=0;
        boolean dispose = true;
        while(dispose){
            System.out.println("请选择输入的是角度还是弧度？（1=角度/2=弧度/其它=退出）");
            try{
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                s=in.readLine();
            }
            catch(IOException e){}
            mode=Integer.parseInt(s);
            
            switch(mode){
                case 1:
                    System.out.println("请输入一个角度：");
                    try{
                        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                        s=in.readLine();
                    }
                    catch(IOException e){}

                    angle=Double.parseDouble(s);//角度
                    //转弧度
                    double radian=Math.toRadians(angle);
                    System.out.println("角度"+angle+"的"+"正弦值为："+Math.sin(radian));
                    System.out.println("角度"+angle+"的"+"余弦值为："+Math.cos(radian));
                    break;
                case 2:
                    System.out.println("请输入一个弧度：");
                    try{
                        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                        s=in.readLine();
                    }
                    catch(IOException e){}
                    angle=Double.parseDouble(s);
                    System.out.println("弧度"+angle+"的"+"正弦值为："+Math.sin(angle));
                    System.out.println("弧度"+angle+"的"+"余弦值为："+Math.cos(angle));
                    break;
                default:
                    dispose=false;
                    System.out.println("期待下次再见！");
                    break;
            }
        }
    }
}
